//package com.example.springai.config;
//
//import com.example.springai.function.HotNewsFunction;
//import com.example.springai.function.MockWeatherService;
//import com.fasterxml.jackson.annotation.JsonClassDescription;
//import jakarta.annotation.Resource;
//import org.springframework.ai.chat.client.ChatClient;
//import org.springframework.ai.chat.prompt.Prompt;
//import org.springframework.ai.model.ModelOptionsUtils;
//import org.springframework.ai.model.function.FunctionCallback;
////import org.springframework.ai.model.function.FunctionCallbackWrapper;
//import org.springframework.ai.model.tool.ToolCallingChatOptions;
//import org.springframework.ai.openai.OpenAiChatModel;
//import org.springframework.ai.openai.OpenAiChatOptions;
//import org.springframework.ai.openai.api.OpenAiApi;
//import org.springframework.ai.openai.api.ResponseFormat;
//import org.springframework.ai.tool.ToolCallback;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Description;
//import org.springframework.stereotype.Component;
//import org.springframework.web.client.RestTemplate;
//
//import java.lang.reflect.Method;
//import java.util.Map;
//import java.util.Set;
//import java.util.function.Function;
//
//@Configuration
//public class AIConfig {
//
//    @Resource(name = "apiRestTemplate")
//    RestTemplate apiRestTemplate;
//
//    @Autowired
//    private ToosBeanFetcher beanFetcher;
//
//    //    @Autowired()
////    OpenAiApi openAiApi;
//    @Bean("chatClient")
//    public ChatClient getChatClient(ChatClient.Builder chatClientBuilder) {
////        chatClientBuilder.defaultTools();
//        return chatClientBuilder.defaultSystem("请用中文回答").build();
//    }
//
//    private Method method;
//    private OpenAiChatModel deepseekChatModel;
//
//    private Prompt prompt;
//
//    public AIConfig(OpenAiChatModel deepseekChatModel) {
//        this.deepseekChatModel = deepseekChatModel;
//    }
//
//    public OpenAiApi.ChatCompletionRequest createChatRequestFunction1() throws Exception {
////        ChatRequest.Message system = new ChatRequest.Message("system", "你是公司内部的AI助手，请格式化输出内容到html的<body>标签中");
//        if (method == null) {
//            method = OpenAiChatModel.class.getDeclaredMethod("createRequest", Prompt.class, boolean.class);
//            method.setAccessible(true);
//        }
//        prompt = new Prompt("你是公司内部的AI助手，请格式化输出内容到html的<body>标签中", OpenAiChatOptions.builder()
//                .responseFormat(ResponseFormat.builder()
//                        .type(ResponseFormat.Type.TEXT)
//                        .build())
//                .toolNames(Set.of("queryMajorCount", "queryCollegeCount", "queryHotSchool", "addSchool"))
//                .build());
//        return (OpenAiApi.ChatCompletionRequest) method.invoke(deepseekChatModel, prompt, false);
//    }
//
//    public ToolCallingChatOptions getToolCallingChatOptions() {
//        ToolCallingChatOptions toolCallingChatOptions = (ToolCallingChatOptions) prompt.getOptions();
//        return  ModelOptionsUtils.copyToTarget(toolCallingChatOptions, ToolCallingChatOptions.class, OpenAiChatOptions.class);
//    }
//    public Map<String, ToolCallback> getFunctionCallbacks() {
//        return beanFetcher.ToosBeanFetcher();
//    }
//
//
////    @Bean(name = "CurrentWeather")
////    @Description("查看当地天气温度") // function description
////    public Function<MockWeatherService.Request, MockWeatherService.Response> currentWeather() {
////        return new MockWeatherService();
////    }
//
//
//}
//
